@file:Suppress("UNUSED")

package com.zxhhyj.ui.view.item

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.LocalContentColor
import androidx.compose.material.LocalTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.zxhhyj.ui.theme.LocalColorScheme
import com.zxhhyj.ui.theme.LocalDimens
import com.zxhhyj.ui.theme.LocalTextStyles

internal val DefaultMinHeight = 24.dp

@Composable
fun Item(
    icon: (@Composable () -> Unit)? = null,
    text: @Composable () -> Unit,
    subText: @Composable () -> Unit,
    actions: @Composable () -> Unit = {},
    enabled: Boolean = true,
    onClick: () -> Unit
) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .clickable(enabled = enabled, onClick = onClick)
            .padding(
                horizontal = _root_ide_package_.com.zxhhyj.ui.theme.LocalDimens.current.horizontal,
                vertical = _root_ide_package_.com.zxhhyj.ui.theme.LocalDimens.current.vertical
            )
            .heightIn(min = _root_ide_package_.com.zxhhyj.ui.view.item.DefaultMinHeight),
        verticalAlignment = Alignment.CenterVertically
    ) {
        CompositionLocalProvider(LocalContentColor provides if (enabled) _root_ide_package_.com.zxhhyj.ui.theme.LocalColorScheme.current.highlight else _root_ide_package_.com.zxhhyj.ui.theme.LocalColorScheme.current.disabled) {
            icon?.let {
                it()
                Spacer(modifier = _root_ide_package_.androidx.compose.ui.Modifier.Companion.width(_root_ide_package_.com.zxhhyj.ui.theme.LocalDimens.current.vertical))
            }
        }
        Column(
            verticalArrangement = Arrangement.Center,
            modifier = Modifier.weight(1.0f)
        ) {
            CompositionLocalProvider(
                LocalTextStyle provides _root_ide_package_.com.zxhhyj.ui.theme.LocalTextStyles.current.main,
                LocalContentColor provides if (enabled) _root_ide_package_.com.zxhhyj.ui.theme.LocalColorScheme.current.text else _root_ide_package_.com.zxhhyj.ui.theme.LocalColorScheme.current.disabled
            ) {
                text()
            }
            CompositionLocalProvider(
                LocalTextStyle provides _root_ide_package_.com.zxhhyj.ui.theme.LocalTextStyles.current.sub,
                LocalContentColor provides if (enabled) _root_ide_package_.com.zxhhyj.ui.theme.LocalColorScheme.current.subText else _root_ide_package_.com.zxhhyj.ui.theme.LocalColorScheme.current.disabled
            ) {
                subText()
            }
        }
        Row(horizontalArrangement = Arrangement.spacedBy(_root_ide_package_.com.zxhhyj.ui.theme.LocalDimens.current.horizontal / 2)) {
            actions()
        }
    }
}